home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / winlib.lzh / WINLIB / ACCS.C next >
Encoding:
C/C++ Source or Header  |  1994-03-30  |  3.8 KB  |  112 lines

  1. /********************************************************************
  2.  *                                                                    *
  3.  *    Accessory and process routines                                    *
  4.  *    by Ken Hollis                                                    *
  5.  *                                                                    *
  6.  *    Find accessory names, find process names (background processes) *
  7.  *    call accessories, and call processes through menubars.            *
  8.  *                                                                    *
  9.  *    Copyright (C) 1994, Bitgate Software and Clever Bits            *
  10.  *    All Rights Reserved.                                            *
  11.  *                                                                    *
  12.  *    Use of the Accessor's file is dormant as of now.  We don't use    *
  13.  *    it because we don't know how to get the correct names of the    *
  14.  *    accessories.  We know how to call, just not what menu order        *
  15.  *    the menus are in.                                                *
  16.  *                                                                    *
  17.  ********************************************************************
  18.  *                                                                    *
  19.  *    Update logs:                                                    *
  20.  *    [12.3.94] Ken Hollis                                            *
  21.  *        WInitProcesses    - added accessory setup from The Accessor    *
  22.  *        UseInternalAccs    - for TOS 1.0 users and under (couldn't        *
  23.  *                          figure out accessory calling method)        *
  24.  *                                                                    *
  25.  ********************************************************************/
  26.  
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include "winlib.h"
  30.  
  31. LOCAL OBJECT menuint[] = {
  32.   /* Tree #0*/
  33.   {  -1,   1,   4,0x0019,0x0000,0x0000, (long)(0x00000000L),   0,   0,  80,  25},
  34.   {   4,   2,   2,0x0014,0x0000,0x0000, (long)(0x00001100L),   0,   0,  80, 513},
  35.   {   1,   3,   3,0x0019,0x0000,0x0000, (long)(0x00000000L),   2,   0,   6, 769},
  36.   {   2,  -1,  -1,0x0020,0x0000,0x0000, (long)(" Desk"),   0,   0,   6, 769},
  37.   {   0,   5,   5,0x0019,0x0000,0x0000, (long)(0x00000000L),   0, 769,  80,  23},
  38.   {   4,   6,  13,0x0014,0x0000,0x0000, (long)(0x00ff1100L),   2,   0,  19,   8},
  39.   {   7,  -1,  -1,0x001c,0x0000,0x0000, (long)("  Back to program  "),   0,   0,  19,   1},
  40.   {   8,  -1,  -1,0x001c,0x0000,0x0008, (long)("-------------------"),   0,   1,  19,   1},
  41.   {   9,  -1,  -1,0x001c,0x0000,0x0000, (long)("  Desk Accessory 1 "),   0,   2,  19,   1},
  42.   {  10,  -1,  -1,0x001c,0x0000,0x0000, (long)("  Desk Accessory 2 "),   0,   3,  19,   1},
  43.   {  11,  -1,  -1,0x001c,0x0000,0x0000, (long)("  Desk Accessory 3 "),   0,   4,  19,   1},
  44.   {  12,  -1,  -1,0x001c,0x0000,0x0000, (long)("  Desk Accessory 4 "),   0,   5,  19,   1},
  45.   {  13,  -1,  -1,0x001c,0x0000,0x0000, (long)("  Desk Accessory 5 "),   0,   6,  19,   1},
  46.   {   5,  -1,  -1,0x001c,0x0020,0x0000, (long)("  Desk Accessory 6 "),   0,   7,  19,   1}
  47. };
  48.  
  49. OBJECT *INTERNALMENU = menuint;
  50.  
  51. ACCS Accessories[6];
  52.  
  53. GLOBAL void WInitProcesses(void)
  54. {
  55.     FILE *fh;
  56.     int i = 1;
  57.     char *fil;
  58.  
  59.     RFix_ObjectPos(INTERNALMENU);
  60.  
  61.     if ((fh = (FILE *) fopen(".\\WLACC.INF", "r")) == NULL) {
  62.         if (AES_VERSION<0x0400)
  63.             form_alert(1,"[3][The Accessor must be run|in the AUTO folder|in order to access|accessories from this|program.][ Okay ]");
  64.     } else {
  65.         do {
  66.             Accessories[i].accname = (char *) malloc(8);
  67.  
  68.             if((fil = fgets(Accessories[i].accname, 9, fh))!=NULL) {
  69.                 Accessories[i].acchandle = (appl_find(Accessories[i].accname));
  70.                 Accessories[i].accposition = (appl_find(Accessories[i].accname)) - 2;
  71.             }
  72.  
  73.             i++;
  74.         } while((fil!=NULL) && (i<6));
  75.  
  76.         fclose(fh);
  77.     }
  78. }
  79.  
  80. GLOBAL void WOpenAccessory(int buffernum)
  81. {
  82.     int msg_buf[8];
  83.  
  84.     msg_buf[0] = AC_OPEN;
  85.     msg_buf[1] = Ap_ID;
  86.     msg_buf[2] = 8;
  87.     msg_buf[3] = 0;    /* Reserved */
  88.     msg_buf[4] = Accessories[buffernum].accposition;
  89.  
  90.     appl_write(Accessories[buffernum].acchandle, 16, msg_buf);
  91. }    
  92.  
  93. GLOBAL void WCallAccessory(int buffernum)
  94. {
  95.     int menu = 0, i = 0;
  96.     BOOL found = FALSE;
  97.  
  98.     do {
  99.         i++;
  100.         if (Accessories[i].accposition == buffernum) {
  101.             menu = i;
  102.             found = TRUE;
  103.         }
  104.     } while((i!=6) && !found);
  105.  
  106.     WOpenAccessory(menu);
  107. }
  108.  
  109. GLOBAL void WUseInternalAccs(int show)
  110. {
  111.     menu_bar(INTERNALMENU, show);
  112. }